Hi Orfeas,
If you use Google, you can find the different types of visas available to foreigners. In your case, it may be "Regroupement Familial" but you are not married yet, so that may complicate it. If you want a visa that will allow you to stay beyond the 30 days of a typical tourist visa that you can buy at the airport, then you need to get an extendable visa at the Malagasy consulate in your country (or the nearest one that will handle your nationality). Yes, it will take some time (there are reasons that underdeveloped countries are underdeveloped!). However, with that visa, you can commence the renewal process without having to leave the country.
You may end up having to get married first, then leave the country to get your extendable visa.
Good luck!