Moved the mask for arrays with missing costs in the engine

This is the companion to https://github.com/gem/oq-engine/pull/1627.
The tests are green: https://ci.openquake.org/job/zdevel_oq-risklib/150/