Made hdpmodel.py and ldamodel.py compatible with py3.0+

These changes do not break py2.6-2.7 compatibility.