Ensure output is utf-8

This was a problem for python2 when piping to another process or when being
called from inside VIm, as python would try to convert everything to ascii,
causing UnicodeDecodeErrors.
Migrate to python3