finished, untested code for blendimages