Improved encoding switch by raw buffer (fixes #42)