unpack-image: small cleanup changes
unpack-image: more error checking and file cleanup