Maybe you already completed your project, maybe you already knew about Charlieplexing (https://en.wikipedia.org/wiki/Charlieplexing), maybe it doesn't apply to your case as your controller didn't support tristate output, but, just in case you didn't know about it:
It's a technique for controlling (or reading) large numbers of LEDs, switches, etc, with surprisingly little wiring. Instead of the usual X/Y of multiplexed I/O, the wiring is diagonal. To control 12 outputs (36 in groups of 3) you'd need just 4 pins (if your lamps are not LEDs, though, you probably need to put some diodes in there)
It's a technique for controlling (or reading) large numbers of LEDs, switches, etc, with surprisingly little wiring. Instead of the usual X/Y of multiplexed I/O, the wiring is diagonal. To control 12 outputs (36 in groups of 3) you'd need just 4 pins (if your lamps are not LEDs, though, you probably need to put some diodes in there)