Fix orientation when creating image thumbnails