Fixed updating of image layer

When changing the transparent color or the image of an image layer,
the item was not resizing and repainting correctly.

Back-ported from master branch commits:

7ded5d6b9fba6d71740fc3ab0c5e2263c51707ec (small part)
479a288d3b4e6105b56a75283e435f79fbde715d