override to_tempfile so that we can use external files