Fix Python 3 bug in PS backend.
Another Python3 bytes/unicode fix
Flush file handles at the end, since Python 3 won't do it for us.