lockfile: python2/3 compat
Ensure that filenames are binary, files are read to and from as binary,
and that, prior to writing to or from files, they internal messages are
When writing a filename to stdout, it should be unicode.
This commit is based on D1136.
Reviewers: mmodell, Release-Engineering-Team, ATIFAND
Reviewed By: mmodell, Release-Engineering-Team, ATIFAND
Differential Revision: https://phabricator.wikimedia.org/D1137