Moved common code from environment subclasses to CommonEnvironment

- `get_os_string` is already in CommonEnvironment and does not need to
  be redefined.
- Moved `is_file` method to CommonEnvironment.
- Converted methods of environment classes from `staticmethod` to
  `classmethod`.
- Added or corrected many docstrings.
Fixed dangerous kwarg default

Never use mutable objects as kwarg default.
Fixed many encoding-related bugs

The most important lesson to take away from this is:

 1. Always use the `unicode_literals` future import
 2. Always decode input
 3. Always use unicode internally
 4. Always encode output

There should never be a `print(value)` statement in this code without an
`.encode(DEFAULT_ENCODING)` call, unless you're sure that the value is
already a bytestring or that the value safely converts to ASCII.