Masking is done using DataCollatorForLanguageModeling so you can use any dataset and just pass the collator to DataLoader.
One thing to note:
DataCollatorForLanguageModeling does dynamic masking but BERT was trained using static masking .