Better encoding support for JRuby

Tests still passing perfectly for 1.9.3, down from 4 to 1 errors for JRuby 1.7.2.