7.0 fix 1319095

Use NamedTemporaryFile instead of file and of deprecated mktemp. That way we ensure 2 files created at the exact same time will have a unique name

Copied from https://code.launchpad.net/~camptocamp/openobject-addons/7.0-fix-1319095