Added optional output of final image.
Changed LowestCost to UniformCost.