dg_mosaic.py: Make it work for python 2.4, 2.6, 2.7