Extending masked array comparison

Work completed in #1074 only to go into v1.6.x
Required for a bugfix.