Masters before Math PHD?
Yes, high grades and excellent letters of recommendation from the master's program can help overcome poor grades from earlier. 

Remember you will apply for the PhD program a year in advance, so the professors you have the first two semesters in the master's program will be the ones you need to ask for letters. You need to be excellent from the start of the master's program. 

The other thing that can help overcome bad grades (to some extent) is a high score on the math subject GRE. You want to study thoroughly for that, unless you already have a high score. See e.g.  What is the median math GRE subject score for admission to a Group 2 or 3 PhD program in applied mathematics?