The data preparation as well as the data loading might depend a bit on the overall model and training structure.
I.e. what kind of model would you like to use?
If your desired architecture accepts the input image containing the complete text, your suggestion of loading the image together with the text (and encode it) sounds reasonable.
This tuturial 9 gives you more information on how to write a custom Dataset.
For a general text processing turotial you migh have a look at the Seq2Seq tutorial 17.