Both work. If you want a 1 dimensional output you save a few parameters and would be doing binary classification on each pixel. You would need to use binary cross entropy as your loss function and choose a threshold for your final predictions. With a >2 dim output you can use a softmax across the channel dimension and use cross entropy, you probably see this more because it generalizes to multiple classes (segmenting cars, tree, road, and background) at once.