Another undergrad or a masters degree before PhD?
To switch from CS to math, you have to show you have enough math courses.  You didn't talk about that.

Poor grades in the first two years don't matter very much. 

Your grades in your math classes and your more theoretical CS classes will carry more weight than, say, a class in operating systems or a very coding-intensive class.

You might need to pick out the key classes you think support your application the most strongly, and put them in a table, showing the course title, brief description if the title is not self-explanatory, and the grade.

Financial considerations could be important.  If you would have to go into debt to finance further studies, then you might want to get a master's in CS, with a TA-ship, but load yourself up with math and math-oriented courses as part of the master's.

It's not clear to me where you would do the master's.  Are you thinking about doing it in the same university where you're doing the Bachelor's?  If not, moving to a new school brings a lot of unknowns.  On the other hand, if your current university is not a great fit for you, for whatever reason, then it could be beneficial to go elsewhere for a master's.

One difference between taking extra classes as an undergrad and doing a master's is that if you take a 500 level class where both seniors and first-year grad students are enrolled, expectations will be higher for the grad students.  AND note that as a grad student you would be expected to earn an A or A- (or a B in the worst case).

Note that if you want to take more math classes at your current institution, there are two additional options that you have not mentioned:
- just wait to graduate, and take some more classes
- go ahead and graduate, and then take some more classes as a non-matriculated student

If I were going to evaluate your admission application (that is a big if -- I have never sat on an admissions committee), I would want to see that after three years of college studies, you started to take things more seriously, you started to do very well, and you started to take more responsibility and initiative.

Taking the initiative means finding math classes that help you mature as a mathematician.

So, bottom line: I think you should expend your energy choosing classes wisely.  I think that matters more than exactly what your status is when you take those classes.