fixed error in open() + tempfile.NamedTemporaryFile