added all features from #3 and fixed image rotation bug