Fix slicing of a single element in an NDData with mask or flags

Closes #2170