Fix errors thrown by Python 3

Encode data as UTF-8 before taking digest
Change floats to int for use as list indices