Use tempfile.mkstemp to get a closable tempfile

This makes sure we don't run out of file descriptors if many images get
loaded into Picard.