Introduce compatibility methods for getting/setting env vars.

Introduces two new methods:

* dxpy.compat.get_env_var(name, default=None) => unicode

* dxpy.compat.set_env_var(name, value)

  value may be bytes or unicode in python2 but must be unicode in
  python3.
Prevent temp file pollution in "dx get" test.

Also refactor to use context-managed chdir in a few other places.