Fix base58 encoding function for python 3