fixed #16 - bugs in binary writer