BUG: preserve ndarray subclasses in median

closes gh-3846
Merge pull request #3851 from juliantaylor/median-subclass

BUG: preserve ndarray subclasses in median