support for image orientation

fix for issue #316