Fix #1419. Use memoryview instead of deprecated buffer.

Buffer is deprecated in python 3 in favour of memoryview, which was added in 2.7.