toBuffer done and fixes to toOctets