Thank you a lot  @ptrblck for your code. I created the rotation function I wanted to have with your lines 21-33.
I have just changed the centor location to x_mid=im.size(2) / 2 and y_mid=im.size(2)/ 2. as the +1 is already included into the im.size. Hope I am right. It improved quite a lot my rotation.