maybe we can extract this computation of `numBuffers` to a helper method so that it can be used by both toChannelBuffer and writeTo?