convert some utilities to generators; add basic image handling