Fix importing and dir creation problems for Python 2.