build and compress data into tmp file