refactor ciimage business a bit