Use ruby's Encoding support for tidy_bytes

The previous implementation was quite slow. This leverages some of the
transcoding abilities built into Ruby 1.9 instead. It is roughly 96%
faster.

The roundtrip through UTF_8_MAC here is because ruby won't let you
transcode from UTF_8 to UTF_8. I chose the closest encoding I could
find as an intermediate.
Merge pull request #10355 from burke/master

Use Ruby's native Encoding functionality to implement `tidy_bytes`