Replace encoding override with improved stdio wrappers; use unicode_literals

This further develops our Python 3.3 migration strategy, most importantly Unicode handling.

    - Use "from __future__ import unicode_literals" everywhere.
    - Use "sys.stdin = io.open(sys.stdin.fileno(), encoding=...)". This makes sys.stdin behave like it does on Python 3.3, producing unicode without having to rely on hacks, implicit coercion, or external configuration to fix the Python encoding.
    - Replace sys.stdout and sys.stderr using a subclass of io.TextIOWrapper. This subclass makes sys.stdout and sys.stderr accept Unicode text as they do on Python 3, but if non-Unicode input is given to .write(), it will try to cast it to Unicode. This provides backward compatibility, and is necessary to make errors show up on sys.stderr on Python 2.
    - Don't wrap the streams more than once.
    - Use an unbuffering sys.stdout wrapper for raw_input() on Python 2, since it doesn't know how to flush the wrapped stdout buffer before waiting for stdin.