Need help with PostgreSQL bytea type

Hello, this is my first time in here, so if I need to show you something like code or examples please let me know.

So I’m working with a company which uses PostgreSQL database and has some jpeg files saved to a table in the database with type bytea. After reading the documentation I get that in Cakephp it is treated as binary data. The first problem I have is that when I do a find(‘all’) to the table in where the pictures are, I get the text and numbers data correctly, but the bytea data is retrieved as ‘null’. How can I get the data of the picture and return it as an image to the user? I couldn’t find an example anywhere. Please help!