iOS 7 compatibility and bugfix in image resizing