Cast str and encode checksums for python 3

In addition to these changes, line 153 in toolchain.py throws “Type str doesn't support the buffer API”. It wasn't obvious to me what else needed to be cast as a string, so I tried replacing 153 in toolchain.py with "lines = join_continued_lines(str(stdout.split("\n")))" and 29 in tools.py with "return str(result)", and the same error came up both times.