Make createMask multithreaded.