encode is alias and it gives problems in ruby 2 for whatever reason.