A database is a good optimisation when your data is a huge text file, but for images stored in individual files it is probably overkill and will add some unnecessary overhead.
Another point to consider is that pickle might be a little slow to save/load pytorch Tensors.
As you say, the image decoding seems to take most of the time, so I would suggest writing a small script that loads each image_file.jpg into a torch Tensor, and then uses torch.save to save the result back into a file named image_file.pt or something like that.
Then you would need to modify your loader to torch.load the .pt files instead of loading the image files.