Existence of closed, surjective map defined in the Stone-Cech compactification

I'm not so sure if my "solution" to the following problem is correct. Can you please let me know if is? or what is wrong? I'm new with this stuff so sometimes I get confused with it.

Anyway here it is:

Suppose $Y$ is an arbitrary compactification of $X$, if $\beta X$ is the Stone-Cech compactification, prove there is a continuous, surjective closed map $g: \beta X \rightarrow Y$ that equals the identity on X.

My work:

Since $Y$ is a compactification of $X$ then by definition it is a Hausdorff compact space which contains a dense copy of $X$, so we can view $X$ as a subspace of $Y$. Hence we can consider the inclusion map $i: X \rightarrow Y$. This is certainly continuous so by the universal property of extension there exists a cts extension:$g: \beta X \rightarrow Y$. So all it remains to show is that $g$ is surjective and closed. Now it is closed because $\beta X$ is compact , $Y$ is Hausdorff and any continuous map from a compact space to a Hausdorff space is closed.

Now to show $g$ is surjective I'm kinda stuck. Here's what I tried. By definition $X$ is dense in $Y$. But $\beta X$ contains $X$ so $\beta X$ is dense in $Y$ as well. Now the continuous image of a dense set is dense hence:

$\overline{g(\beta X)} = Y$

But $\beta X$ is compact and the continuous image of a compact set is compact and a compact subset in a Hausdorff space (Y) is closed so $\overline{g(\beta X)} = g(\beta X)$. Thus $g(\beta X) = Y$.

-
What definition of BX are you using? (Depending on the definition this property is part of the definition.) – Qiaochu Yuan Jan 13 '11 at 23:23
Looks good to me. You've shown $g(\beta X)$ is both dense and closed in $Y$, so it must be all of $Y$. – Nate Eldredge Jan 13 '11 at 23:32
@Nate: Doh, you are right. Cheers! – undergrad Jan 14 '11 at 3:32

We know that $X \mapsto cX$ extends to a continuous map $\beta X \mapsto cX$. And $X \mapsto cX$ has a dense image. It follows that $g: \beta X \mapsto Y$ is surjective.
by $X \mapsto cX$ you mean the inclusion map? or which map? and $cX$ is the compactification of $X$ ? – undergrad Jan 13 '11 at 23:30
@undergrad: $X \mapsto cX$ is the arbitrary compactification $Y$ of $X$. In other words, $Y: X \mapsto cX$ is the arbitrary compactification of $X$. – PEV Jan 13 '11 at 23:33