fix for #10012

the sql statement in image.c:782 was just terribly wrong. while trying to handle
grouped images it would overwrite existing xmp files in adverse conditions.
import: avoid intermingled use of sqlite stmt within dt_image_import()
Merge pull request #636 from upegelow/xmp_overwrite_fix

fix for #10012