tests: put some Python 3 polish on inline Python invocations
A couple of these became inline python sessions because they got more
involved, and one of them is super-annoying and writes directly to
sys.stdout.buffer because I just couldn't make it work any other way.
Differential Revision: https://phab.mercurial-scm.org/D4230