Use tempfile to generate temporary files in tests