changed how strings get encoding to better support JRuby (fixes #9)