Use tempfile as workaround to random errors when accessing network files