Python-magic alternative way
Specify encoding when sampling