Mars and its lesser-known city-sized moon, Deimos, has been imaged by a spacecraft on its way to study an asteroid.