Improve efficiency of encoding detection in Source::Buffer

This fixes #39.