Make backward compatible to Ruby 1.9.3

String in Ruby 1.9.3 does not have bytes method.  Ruby 2.x and later does.