Exporting indices

It feels like it should be basic functionality to be able export a raw indexed image format, even a just CSV or something is all I need. As far as I can tell, I am only able to export traditional image formats such as png, jpg, etc. I looked over the scripting API and I don’t see any obvious way to do what I need to do.

I really need this feature for my project, so if anyone has any ideas or can recommend another indexed-image editor that can actually export the raw data, please let me know.