bpy.data.images["ID"].save_render("XXX") changes color space I tried to save a baked image using 

bpy.data.images["Image Id Name"].save_render("C:/path/to/file.png")


but this always changes the colorspace and I couldn't find where to set the colorspace for save render in the
documentation

Finally I solved it by passing the image editor UI area, where the image is in and using bpy.ops.image.save_as

for window in bpy.context.window_manager.windows:
    screen = window.screen
    for area in screen.areas:
        if area.type == 'IMAGE_EDITOR':
            override = {'window': window, 'screen': screen, 'area': area}
            bpy.data.images['bakedTexture'].filepath_raw = filenameVariations
            bpy.ops.image.save_as(override, filepath = filenameVariations)
            print ("Generated file: ", filenameVariations)


For the future, does anyone know how to do it with save_render?

Because the way I did it, I do not have control over compression and image bit depth.

I am on Blender 2.80
Had the same issue but found that the Sequencer (Render Properties tab, Color Management) seemed to be the cause for colorspace change when using save_render. Setting it to "Raw" fixed the issue for me.

bpy.context.scene.sequencer_colorspace_settings.name = "Raw"