Use NamedTemporaryFile rather than fixed tmp path