Using tempfile to keep content type intact