If 'flush' flag is enabled when calling decoding/encoding function, flush buffer when input run out (satisfies test 'SufficientByteArray').
Better and more homogeneous error handling.
Reverted changes of commit 6ad7f75a3777652a535ef4356e6d193eed4ed612