I believe the question whether $X$ can be chosen to be Hausdorff was left open by both existing answers. The solution is provided by the H-closed spaces of Henno Brandsma's comment. I shall answer the question from that comment in the positive.

**Proposition.** A Hausdorff space $X$ is H-closed iff it is universally closed.

**Proof.** The "if" direction is trivial.

To prove "only if", we use the well-known fact that a Hausdorff space is H-closed iff every open cover of $X$ contains a finite collection of sets whose *closures* cover $X$. (See the Wikipedia page cited above, or the section on H-closed spaces in *Extensions and Absolutes of Hausdorff Spaces* by Jack R. Porter and R. Grant Woods.)

So suppose $f\colon X\to Y$ is continuous, where $Y$ is Hausdorff, and let $y\in Y\setminus f(X)$. Since $Y$ is Hausdorff, for every $x\in X$ there is a closed neighbourhood $U[x]\subset Y$ of $f(x)$ not containing $y$. Since $X$ is H-closed, there is a finite collection $x_1,\dots,x_k$ such that
$$ X = \bigcup_i f^{-1}(U[x_i]). $$
So
$$ y\in Y\setminus \bigcup_i U[x_i] \subset Y\setminus f(X), $$
and hence $Y\setminus f(X)$ is a neighbourhood of $y$. So $f(X)$ is closed, as claimed. $\blacksquare$

Alternatively, you may consider directly the following simple example of a H-closed space from Porter-Woods. This space is given by
$$ X := \{p^-,p^+\} \cup \{(1/n,1/m)\colon n\in\mathbb{N}, m\in\mathbb{Z}\setminus\{0\}\} \cup \{(1/n,0)\colon n\in\mathbb{N}\}.$$
$Y:=X\setminus\{p^-,p^+\}$ has the usual topology induced from $\mathbb{R}^2$, while a neighbourhood of $p^+$ (resp. $p^-$) should contain all points $(1/n,1/m)$ with sufficiently large $n$ and positive (resp. negative) $m$.

It is easy to verify directly that this space is universally closed (and H-closed).

As noted in Pietro's answer, the map from a universally closed space to its Stone-Cech compactification is surjective. The question remains whether there is a space with the latter property which is not H-closed.