add functions to commonutil.py and imageutil.py