releaseimage might double free if we only match pointers
to image data.  so revert to memcpy