Fixed issue where saving image to file crashes app