fix #3277: NPE when saving a scaled image