fix handling of temporary files