Fixed a bug in bufferpool.write