Exporting RGB image with vector layers

Please have a look at this thread

And especially to my second reply in this thread. There I link to this example source code.

The Problem is that this code is Java not Python. Maybe you can translate it or someone can help?