Fix some problems with rendering of images