Temporary file with specific file extension in Python 3
This doesn't work for you?
In [2]: tempfile.NamedTemporaryFile(suffix='.tif').name
Out[2]: '/var/folders/gq/swc6jtld5853skyq_xc2lpc40000gn/T/tmplrtwvxg7.tif'
did you try?
fd, path =tempfile.mkstemp(suffix = '.tif')
print(path)