Add util functions for converting toBuffer and toArrayBuffer