How can I prove this relation between the images of these two different sets? 
If $f : X \to Y$ is surjective, prove that every $A\subset X$ satisfies 
  $$Y\setminus f(A) \subset f(X\setminus A). $$
  Show that the claim is false is $f$ is not surjective. 

I was able to come up with a counterexample for when $f$ is not surjective, but I am not sure how to formally prove the statement to be true when $f$ is surjective. Any help would be greatly appreciated. 
 A: Suppose $y \in Y \setminus f(A)$. There exists $x \in X$ such that $f(x) = y$, by surjectivity. We claim $x \notin A$: suppose $x \in A$, then $y = f(x) \in f(A)$, contradiction. So $x \in X \setminus A$, i.e. $y \in f(X \setminus A)$. Since this held for all $y \in Y \setminus f(A)$, we conclude $Y \setminus f(A) \subseteq f(X \setminus A)$. 
A: Explain it in words. Call elements of $A$ to green elements in $X$. The LHS is the the codomain with all the images of green elements removed. SInce remaining elements are (by surjectivity) are images some elements it is tempting to say they have to be among the images of non-green elements. Unfortunately a green element can very well have the same image as a red element. So removal 
 green image may also remove the images of many non-green elements.
A: If $y \notin f(A)$, then $f^{-1}(y) \cap A = \varnothing$.
By surjectivity, if $y \in Y$, then $f^{-1}(y) \ne \varnothing$.
Therefore, if $y \in Y \setminus f(A)$, then $f^{-1}(y) \ne \varnothing$ and $f^{-1}(y) \cap A = \varnothing$. This implies $f^{-1}(y) \setminus A = f^{-1}(y) \ne \varnothing$, so $f(f^{-1}(y) \setminus A) = f(f^{-1}(y)) = \{y\}$. The the union to get
$$
Y \setminus f(A) = \bigcup_{y \in Y \setminus f(A)}f(f^{-1}(y) \setminus A)
\subseteq \bigcup_{y \in Y}f(f^{-1}(y) \setminus A) = f(X \setminus A).
$$
A: Here is yet another proof: let's take $\;Y \setminus f[A] \;\subseteq\; f[X \setminus A]\;$, and just expand the definitions and simplify using the rules of predicate logic.
Now we have for every $\;A\;$ that
\begin{align}
& Y \setminus f[A] \;\subseteq\; f[X \setminus A] \\
\equiv & \qquad \text{"definition of $\;\subseteq\;$; definition of $\;\setminus\;$"} \\
& \langle \forall y :: y \in Y \land y \not\in f[A] \;\Rightarrow\; y \in f[X \setminus A] \rangle \\
\equiv & \qquad \text{"definition of $\;\cdot[\cdot]\;$, twice; definition of $\;\setminus\;$"} \\
& \langle \forall y :: y \in Y \land \lnot \langle \exists x : x \in X \land f(x) = y : x \in A \rangle
  \\ & \phantom{\langle \forall y :: }
  \Rightarrow\; \langle \exists x : x \in X \land f(x) = y : x \in X \land x \not\in A \rangle \rangle \\
\equiv & \qquad \text{"logic: extract $\;y \in Y\;$; DeMorgan on first $\;\exists\;$; remove last $\;x \in X\;$"} \\
& \langle \forall y : y \in Y : \langle \forall x : x \in X \land f(x) = y : x \not\in A \rangle
  \\ & \phantom{\langle \forall y : y \in Y : }
  \Rightarrow\; \langle \exists x : x \in X \land f(x) = y : x \not\in A \rangle \rangle \\
(*) \;\;\; \equiv & \qquad \text{"logic: $\;\forall \Rightarrow \exists\;$ iff the quantification range is not empty"} \\
& \langle \forall y : y \in Y : \langle \exists x :: x \in X \land f(x) = y \rangle \rangle \\
\equiv & \qquad \text{"definition of surjectivity"} \\
& f\text{ is surjective} \\
\end{align}
Note how the key step is $(*)$, while the other steps are really mechanical definition unfoldings and simplifications.
