Improved IO routines reading the binary data.

In order to be able to deal with large datasets (multi GB)
the code precalculates the required buffer size and allocates
a buffer of sufficient size before parsing. This avoides re-allocation
of the backing buffer which otherwise could lead to significant
memory waste due to uncollected memory.