map images and refs into flat objects