replace NamedTemporaryFile with tmpfile

For windows compatibility