torch.save can also save tensors, not only the state_dict.
You could add the following line to your current __getitem__ and store each image tensor in a folder corresponding to the label:
...
for line in buffer:
   ...
x = torch.tensor(image)
torch.save(x, self.folder + '/' + str(label) + '/' + str(index) + '.pth')
return x, torch.tensor(label)

This will save each image tensor in a folder given by str(label).
The file names won’t be ascending, i.e. you might end up with:
root/
── 0/
│   ├── 24.pth
│   ├── 4678.pth
│   ├── 4679.pth
│   └── ...
├── 1/
│   ├── 0.pth
│   └── 1.pth

After saving all files (just run this code for one single epoch), you should rewrite your Dataset by providing the file paths to its __init__ and just loading each image tensor using torch.load in __getitem__.
Let me know if you get stuck somewhere.
PS: Alternatively, you could also save the images using PIL and later just use an ImageFolder as your dataset.