What you have looks great!
Because the a that we're talking about is the net acceleration of the whole system, replacing those tensions with the corresponding masses multiplied by a would be incorrect. This is because tension is not the only force present on two of the three masses. To see why this wouldn't be right, imagine replacing the tension in your ##m_C## equation with the ##m_Ca## product you suggest. You would get that ##m_Ca = m_Ca + m_Cg## which is equivalent to writing ##m_Cg = 0## and we know that's not true! You could make the replacement you suggest in the first equation, but that would just be redundant and not helpful.
Now, take a little while to think about the tensions you have in each equation and how they may or may not relate to the other tensions. I think you can solve the rest of the problem from here. Just make sure that if you add something to one side of an equation, you add the same thing (or something equivalent) to the other side to keep the equality true. Try not to make another reply at the first sign of trouble. You should be able to think through it from here :) After a while, if you just can't get it, I'll try to offer a little more help based on what you've done.