add py3compat.buffer_to_bytes_py2

casts buffer objects to bytes, which is needed for pickle.loads from buffers on Python 2.

closes #7101