create_tmp_packfile(): a helper function