[[ Bugfix 13706 ]] Fix a bug in the image saving code causing stackfile ...

...corruption