Fixed crash on Python3 with replacing an image