Thanks you Bas van den Broek for pointing me into the right direction to solve this challenge. I have managed to create a custom request handler by using this blog post on the Mendix blog and by peeking into the java source code of the DeepLink module and the Creative Commons String utils.
I did the following to get this to work for images:
Follow the steps from the blog [here] as was already mentioned in this post
Get rid of the 'toJSONString(..)'' method as we don't need it for images
Ensure that the object you retrieve inherits from the FileDocument entity, i retrieve it by FileID
Replace the code that creates the streams by the following:
OutputStream outputStream = response.getOutputStream();
InputStream answerStream = Core.getFileDocumentContent(systemContext, ourObject);
Register your Requesthandler URL also in your cloud environment configuration (separate tab for that) so that is also works in the cloud
Theo - check out the DeepLink module in the appstore. With deeplink, you should be able to build a microflow that retrieves and downloads an image.