Automatic rotation of JPEGs