I am referencing the proof located at http://www.maths.nuigalway.ie/MA416/section3-4.pdf, Theorem 3.4.2.
I am only looking at the right to left direction. I understand the following:
Let $a \in I, a \not\in M$.
$\rightarrow a + M$ is not the zero element of $R/M$.
$\rightarrow \exists \; b \in R \;$ s.t. $\;(a+M)(b+M) = 1 + M$.
$\rightarrow ab-1 \in M$ *
Define $m = ab-1$.
$\rightarrow 1=ab-m$
$\rightarrow 1 \in I$ *
Except the starred steps, I do not understand how those were obtained from the information provided before them.
For $ab - 1 \in M$. The previous step was $(a + M)(b + M) = 1 + M$. Note that $(a + M)(b + M) = ab + M$ by definition so $ab + M = 1 + M$. This says in particular that $ab \in 1 + M$ so there is an $m \in M$ such that $ab = 1 + m$. But then $ab - 1 = m$ for some $m \in M$.
For $1 \in I$ note that $a \in I$ and $I$ is an ideal so $ab \in I$. Also $m \in M$ and $M$ is contained in $I$ so $m \in I$. Thus $ab - m$ is contained in $I$, but $ab - m = 1$ so $1 \in I$.