PHOT-20: bug fix in delete image function.