The simplest method two prove two sets are equal is to show that each one is contained in the other.
The simplest method to show that one set is contained in the other is to show that any element in the one set is also an element in the other.
Here you will want to show that
$$f(X\cup Y)\subseteq f(X)\cup f(Y)\quad\text{and}\quad f(X)\cup f(Y)\subseteq f(X\cup Y)$$
both hold.
For example, to show that $f(X\cup Y)\subseteq f(X)\cup f(Y)$, let $b\in f(X\cup Y)$. We need to show that $b\in f(X)\cup f(Y)$; that is, we need to show that either $b\in f(X)$, or $b\in f(Y)$.
Since $b\in f(X\cup Y) = \{f(a)\mid a\in X\cup Y\}$, there exists $a\in X\cup Y$ such that $b=f(a)$. Since $a\in X\cup Y$, either $a\in X$ or $a\in Y$. If $a\in X$, then $b=f(a)\in f(X)\subseteq f(X)\cup f(Y)$, and we are done. If $a\in Y$, then $b=f(a)\in f(Y)\subseteq f(X)\cup f(Y)$, and we are done. Since these are the only cases, we see that if $b\in f(X\cup Y)$, then $b\in f(X)\cup f(Y)$. This proves the first inclusion.
I'll let you work out the second inclusion.