BF - preserve masked arrays during aggregation

During aggregation masked arrays were being converted to numpy arrays. This simple PR prevents this undesirable behaviour by checking the type of the input before constructing the output array.