Replace unicode with str for python 3.
Get real path for tempfile.mkdtemp to fix tests on mac os x.