Bug fixes in image rotation