imgurlib.py: broke out common functions into common module