avoid allocation of new objects, if cube/mask already have correct format

related to #37