I have what I believe is a proof for this question however being how short it is, I have my reservations.
Define the function f continuous on M into R. M compact and connected.
Since M is compact and connected, f(M) is compact and connected. Because M is connected and compact its is either the empty set, {a} the singleton for some a in R, or [a,b] for some a,b in R where a is less than b WLOG. WLOG assume M=[a,b] for some a,b in R (This is where I am not sure if I am allowed to say that) Then f([a,b]) is connected and compact and hence closed and bounded. f(a) does not equal f(b) because f is continuous so by the Intermediate value theorem f takes on every value in-between f(a) and f(b). So f([a,b]) is an interval. Therefore f([a,b]) is an closed interval.
I am sorry for the lack of MathJax I am just learning it now!
I think you're making it more complicated than it needs to be?
Why can't f(a) be equal to f(b) for a given continuous function? The constant function in $\mathbb R$ is a continuous function and it's equal at it endpoints for any $a,b\in \mathbb R$.
If we're only talking in $\mathbb R$, then you just need to look at the Weistrass Extreme Value theorem. If M is compact and $f$ is continuous, then f(M) is bounded and attains its bounds. Call its lower bound c and its upper bound C. That means that $c \leq f(x) \leq C$ for all $x \in M$. Doesn't matter if $M$ is the empty set, a singleton, etc. It's compact, end of argument. Since $f(x)$ attains its bounds, we know the inequalities are inclusive, hence $f(x) \in [c,C]$. Again, if $c=C$ we have the closed interval [c,c] which is indeed just {c}, but no fear, singletons are intervals.
Edit: Whoops. Forgot to use connectedness in the argument. If it's a singleton we're done. If $c\neq C$ then if the domain is not connected, you could have the case where the function maps to a non-interval. Connected sets under continuous functions map to connected sets.