adapted to python 3 for use in blender