You can create a custom dataset class which opens your files with whichever library you need. Think that PIL is chosen  by default but it’s not mandatory. The Drawback is you would lose transformations