The easiest way to apply both transformation would be in my opinion to create a new Dataset.
Since you are lazily loading your images from a folder, we should keep it that way.
Just get all image paths (e.g. with glob) and pass it to the Dataset.
I created a small example, which should give you a good starting point:
class MyDataset(Dataset):
    def __init__(self, data_paths, target, threshold, masks, transform=None):
        self.data_paths = data_paths
        self.target = target
        self.transform = transform
        self.threshold = threshold
        self.masks = masks
    
    def __getitem__(self, index):
        x = Image.open(self.data_paths[index])
        y = self.target[index]
    
        if self.transform:
            x = self.transform(x)
    
         Apply threshold here
        x = x > self.threshold
        x = x.float() # Cast back to float, since x is a ByteTensor now
    
        # Apply mask here
        x = x * self.masks[index] 
    
        return x, y

    def __len__(self):
        return len(self.data_paths)

You can try the binarization and masking with these sample lines:
# Create fake images
data = torch.Tensor(100, 1, 24, 24).random_(0, 255)
print(data)

# Apply threshold
data = data > 128
data = data.float()
print(data)

# Create fake masks for every image
mask = torch.Tensor(100, 1, 24, 24).random_(0, 2)
data = data * mask

Let me know, if this is working for you.