fix #3277: NPE when saving a scaled image
Merge branch 'release' into upstream
refactoring: add more annotations