fixed handling of mask when ngram_mode is not set