Use proper encoding to convert values in various places

Fixes #1072
Compare bytes() objects in matcher functions

Fixes #1071
Add tests for invalid unicode filenames

Ref #1071
Do not use segment_info['buffer'].name ever

This results in UnicodeDecodeErrors for non-unicode filenames