BUG: Masked arrays and apply_over_axes

Masked arrays version of apply_over_axes did not apply
function correctly to arrays with non-trivial masks.

Fixes #4461.
Merge pull request #4463 from abalkin/issue-4461

BUG: Masked arrays and apply_over_axes