Failed my professor months ago, not sure what to do now
I think you are being a little bit too hard on yourself. That said, you acted unprofessionally and were irresponsible in communicating with the professor. The prof may feel like you treated him with a lack of respect, so it is important to make it clear that you do respect him, and that your behavior was selfish and childish.

The best course of action is to come clean. 


Write an email or schedule a call with the professor. 
Apologize for behaving unprofessionally. 
Do NOT make excuses. You can mention that you couldn't have started the masters program because of visa issues, but you should have told him as soon as you discovered that information. Remember, what you did wrong was fail to communicate. Not starting the masters is not the "crime". 
Acknowledge that your behavior was unprofessional. 
Thank them for their mentorship over the years. Take some time to think about what you learned from them and let them know. This demonstrates your maturity and shows that you respect and appreciate him.
Apologize again and mention that you hope that you haven't ruined the relationship.


Assuming the professor is a reasonable adult, they will accept your apology, and you may ask for a reference in the future.