fixes #4322 Script error when you save image in ImageEditor

Fixed the issue and pushed the code for review, please check it.