Fix possible memory leak
Merge pull request #6260 from iSevenDays/patch-8

Fix possible memory leak in Image::saveImageToPNG