remove temp files when done image processing

added null checks for metadata reads