decoder: Code cleanup

- add init method
- better decoding loop
- buffer method returns *void
- bugfixes