Those strings are actually just the visual representation of the values of those bytes in ascii, so you should really be storing them in bytes like objects (which should be the default type you receive TCP/UDP data in). If you are literally receiving a JPG file over the network, then all you have to do write those bytes to a binary file, ala open("file_name.jpg", "wb")
and make sure the new file you've created has .jpg extension. If the data is the same it will be interpreted the same as any old jpg file no matter what medium you sent it over. Its important to store them in byte arrays or the like because you want to make sure the data that you received is actually being written as the physical binary value out, and not a textual version of that string.
There is only one type of file, and that is the binary file. Even text files are binary files. But we separate the idea of "human readable" and "binary" into binary format and text formats. A python file, any .txt formats, those are all text files using this convention. A jpg, png, compiled program, or basically any code whose representation cannot be parsed via ASCii, UDP-8,16,32,64 etc, or any other textual representation is a binary file.
The thing about files is, because they are all actually binary, they are interpreted based on what you tell another program that file is (hence file extensions), and even then if the program permits, you can just ignore the extension and just tell your editor "interpret this as an X file".