Are there any tricks to use less pins?
Yes lots.
When you say pins I am assuming you mean arduino I/O pins. Port expanders are easy to get more outputs as are shift registers. You can also get chips that will do the matrix scanning for you using only 5 pins. Or even charlyplexing chips.
But if you don't say what you want we can't tell you what to use.