Added flipping handling for images