Improve efficiency of encoding detection in Source::Buffer

This fixes #39.
Merge pull request #44 from bbatsov/encoding

Improve efficiency of encoding detection in Source::Buffer