Added code to transform images to a consistent shape.