BUG: Set file encoding for IPython.html.terminal.handlers.

Fixes https://github.com/ipython/ipython/issues/6812.