Since the torchvision.datasets.MNIST dataset returns PIL Images, if you don’t specify a transformation, the easiest way would be to directly save them:
dataset = datasets.MNIST(root=PATH)

for idx, (img, _) in enumerate(dataset):
    img.save('{:05d}.jpg'.format(idx))