#1 fix tempfile issue and some Python 3 stuff