check if image file exists first