refactor and speed up hextree image encoding by using dense_has_map - refs #1629