Fix windows issues.

The environment passed to popen cannot contain Unicode on windows.
Added a class that handles this automatically.

When opening files with "rb" and writing them back with "wt", windows
line endings (cr+lf) turns into double spacing (then quadruple? spacing
etc.).  Fix by writing the file back as "wb" and doing the encoding
explicitly in the write call.