Deal with lack of `buffer` in py3