clone from https://gitorious.org/imageutilities