Python 3 compatibililty for misc_utils.py