Practicing with creating textures at a low level, I came to the conclusion that I was using the Texture class incorrectly. I used the read() method which overrides the previously set parameters. This is not what I want, I switched to the set_ram_image() method, however, I had difficulties.
This is not the solution. Passing a compression mode just disables the size check. But it will crash later on, because the RAM image is not compressed in a way that the GPU will understand. GPUs do not understand PNG-compressed data, the only compression they understand is block compression (DXT et al) or uncompressed, raw image data.
So, you need to decode the .png data first. This can be done via PNMImage, or with Texture.read (passing in a StringStream). set_ram_image will not handle decoding/decompressing for you, it is for raw data only.