support BN in bufferwriter

So that the precision of writing a variable sized integer is sufficient.