You should also read this tutorial: several things at the same time
It will show you have to disassemble your for() loop. You should let the loop() function do the looping. Each time through loop(), with mode ==8, you write a new RGB value.
If you want to get rid of those delay()s as well, check out the Blink Without Delay example in the IDE (File->examples->02.digital->Blink Without Delay) to learn how to track elapsed time.