Fixing bugs in image blending code