Dup string before changing encoding because it might be frozen

Calling String#force_encoding! on a frozen string throws an exception.
By dupping the string we prevent this from happening.

/cc @charliesome @tmm1