Here is a simple implementation to write an iSEG tissue list file, given a dictionary mapping the label index to a name:
https://github.com/dyollb/s4l-scripts/blob/df8e2241f87ca91d71138e9d2b3d4336dadb82dc/src/anisotropic_conductivity/load_labels.py#L44