Added checking for existing of temp image file