fixed bug in binary writer