Remove the need to pass in encoding

Detect the encoding internally. This only affects Python 2.