This is actually somewhat complicated in general, and requires some hypotheses on the space $X$. Namely, $X$ must be completely regular, so if your construction does not use this hypothesis it will not in general give the Stone-Cech compactification. See section 1.34 onward of Russel C. Walker's book "The Stone-Cech Compactification." I believe the ultrafilter construction is initially due to Waldhausen, but Walker's exposition is very readable and I can't find the Waldhausen paper.
The upshot is that in general one wants to consider ultrafilters of zero sets of $X$, rather than ultrafilters of closed sets in general. This is necessary because the closed sets of a non-normal space don't behave nicely--in particular, they aren't separated from one another by continuous real-valued functions. But if you look at the universal property of the Stone-Cech compactification, this is exactly the relevant type of separation, so one needs to look at zero sets instead.
EDIT: In response to Qiaochu's comment, I'm going to make some fuzzy remarks on how much of the topology of a topological space $X$ the category Top sees, as opposed to how much of the topology of $X$ the category of compact Hausdorff spaces sees (call this KHaus). I won't be as formal as possible because I think doing so would risk obfuscating some subtle points--but to point in the direction of a formalization, note that there is a functor $F: Top\to [Top, Sets]$ (where $[-,-]$ denotes the functor category), and a functor $G: Top\to [KHaus, Sets]$ where both functors are given by $X\mapsto \operatorname{Hom}(X, -)$. The question I want to address is---how much of the topology on $X$ can we recover from the functors $F(X), G(X)$?
Now for the first question, Top sees everything about a topological space $X$. This is obvious from the Yoneda lemma, but more explicitly, one can consider the two-point space $A=\{x, y\}$, where the open sets are $\emptyset, \{x\}, \{x, y\}$. Then $\operatorname{Hom}(X, A)$ gives exactly the open/closed sets of $X$, and one can even extract the (closed) sets themselves by taking the pullback of diagrams of the form $X\to A\\leftarrow \{y\}$.
But note that the space $A$ is not contained in KHaus, since $x$ is not a closed point. One should think of KHaus as only seeing "zero sets," or more generally level sets, of functions on $X$. Indeed, given any function $f: X\to Y$ in KHaus, one may extract the level set $f^{-1}(y)$ by taking the pullback of $X\to Y\leftarrow y$ (which may not exist in KHaus, but one can see the functor it represents). On the other hand, if $S$ is a closed subset of $X$ which is not the level set of any function, how do we see it? For example, $\operatorname{Hom}(A, Y)=\operatorname{Hom}(pt, Y)$ for any compact Hausdorff space $Y$---KHaus does not distinguish these two spaces.
The upshot is that KHaus only "sees" zero sets (or more generally, level sets of functions), so any natural functor defined out of KHaus will be built from them, rather than arbitrary closed sets.
EDIT 2: This is an attempt to address Qiaochu's Edit #2. I claim that it suffices to quantify over spaces of cardinality at most that of $X^{\mathbb{N}}$. Indeed, let $C$ be any compact Hausdorff space, and $f: X\to C$ a function. Then it factors through $\overline{f(X)}$ which is closed in $C$ and thus compact Hausdorff, and has cardinality at most $X^\mathbb{N}$. So it suffices to quantify over compact Hausdorff spaces of bounded cardinality.
To see the claim about the cardinality of $\overline{f(X)}$, note that $f(X)$ has cardinality at most that of $X$, and there is a surjective map from convergent sequences in $f(X)$ to $\overline{f(X)}$ (namely taking the limit). But convergent sequences in $f(X)$ are a subset of $f(X)^{\mathbb{N}}$.
Now the class of isomorphism classes of compact Hausdorff spaces of bounded cardinality (or indeed, of topological spaces of bounded cardinality) is clearly a set, which lets the quantification go through.
EDIT 3: Qiaochu points out that I assumed the existence of a locally countable base in the last edit---we can't say that every point is the limit of a sequence; instead one needs to say it's the limit of an ultrafilter. This gives a larger bound on cardinality, but still a bound.
In this paper (Spaces $N\cup\mathscr{R}$ and their dimensions, Topol. Appl.
11(1) 1980 93-102) — I hope the PDF is freely available) Jun Terasawa constructs maximal almost disjoint families on $\mathbb{N}$ whose associated spaces can have any dimension you want. Given an almost disjoint family $\mathcal{A}$ on $\mathbb{N}$ one defines a topology on the union $\mathbb{N}\cup\mathcal{A}$ by declaring each natural number to be isolated and giving each $A\in\mathcal{A}$ a countable local base by putting $$U(A,n)=\lbrace A\rbrace \cup \lbrace i\in A:i\ge n\rbrace$$ for each $n$. This space is locally compact and zero-dimensional but Terasawa could arrange it so that its Čech-Stone Compactification would contain the Hilbert cube, for example.
Dowker's example does have a locally compact version:
Let us retain the notation of Dowker's paper and use $T$ to denote the
set of countable ordinals and $Q_\alpha$ to denote the $\alpha$th
congruence class as chosen by Dowker.
In addition let $\mathbb{A}$ denote Alexandroff's double arrow space.
This is the product $[0,1]\times\lbrace0,1\rbrace$, ordered lexicographically
and endowed with its order topology and with the two isolated points
$\langle 0,0\rangle$ and $\langle 1,1\rangle$ deleted.
Now consider the product $T\times \mathbb{A}$ and define a quotient
space $X$ by identifying the points
$\langle \alpha,x,0\rangle$ and $\langle \alpha,x,1\rangle$
whenever $x\notin\bigcup_{\beta\ge\alpha}Q_\beta$.
It is elementary to verify that this is an upper semicontinuous decomposition
and that the resulting space is locally compact and zero-dimensional.
The key observation is that for every $\alpha$ the product
$T_\alpha\times\mathbb{A}$ is compact and open in the domain and its
image is compact and open in $X$.
Furthermore, arguments similar to those given by Dowker will show that
each finite open cover of $T\times\mathbb{A}$ has a refinement of the
form $\mathcal{U}\cup\mathcal{V}$, where $\mathcal{U}$ is a disjoint
open cover of $T_\alpha\times\mathbb{A}$ for some $\alpha$
and $\mathcal{V}$ consists of finitely many sets of the
form $T\times C$, where $C$ is a clopen interval in $\mathbb{A}$.
The latter can then be used, just as for Dowker's $M$, to show that the bottom
and top lines in $X$ cannot be separated by clopen sets and hence
that $\beta X$ is not zero-dimensional.
Best Answer
No, the closure of the image of $f$ in $Y$ is never the Stone-Čech compactification of $X$ unless $X$ is empty. In particular, consider the element $a\in Y$ which is $1$ on every coordinate. Note that the only open subset of $Y$ that contains $a$ is $Y$ itself. So, if $X$ is nonempty, then $a$ will be in the closure $X_0$ of the image of $f$. This means that $X_0$ contains a point whose only neighborhood is the whole space $X_0$. Also, $a$ is not in the image of $f$ (no element of $X$ is in every closed subset of $X$), so $a$ is not the only point of $X_0$. This means $X_0$ is not $T_1$, so it cannot be the Stone-Čech compactification of $X$.
The main moral here is that the Stone-Čech compactification is not about making a space compact: it is about making a space compact Hausdorff. So if you have some sort of universal construction that does not enforce the Hausdorffness condition, there is no reason to expect to get the Stone-Čech compactification.