How to write an email to a potential PhD advisor that I have worked with in the past
In my opinion, what works best is a personal email (you probably know best how personal is appropriate with that concrete person), with a formal application attached. He might want to discuss your application with some colleagues who do not know you, or with HR. Thus, having the pertinent information will be an advantage. 

In the personal email you might want to mention that you enjoyed the common work you did previously, and that you would like to continue / build up on that, now that you finished the MSc.

Say very directly, that you would prefer his research group over others. And then add something like: in case he has any open PhD positions in the near future, your formal application and CV are attached.