optimise memory consumption

better implementation of the buffer handling. the input data will be
appended consecutively in the buffer, until the buffer is full. the
read operation should be performed in one operation, or will involve a
custom buffer handling.