binary streams refactoring

- changed binary input/output streams so that they are not based on
string buffers but long buffers
- added JUnit tests for these streams