Characteristic classes of the bundle of trace free, skew adjoint endomorphisms In  "Floer Homology groups in Yang-Mills theory", Donaldson says that if we take an $U(2)$-vector bundle $E$ and we construct the bundle $\mathfrak{g}_E$ of trace-free, skew adjoint automorphisms of $E$, ($\mathfrak{g}_E \subset E^*\otimes E$) then we have the following relation
$$w_2(\mathfrak{g}_E) = c_1(E) \ \text{mod}\  2$$
$$p_1(\mathfrak{g}_E) = c_1(E)^2 - 4 c_2$$

Is there some neat way to see this? More generally, can we express the characteristic classes of a bundle associated to a principal bundle $P$ in terms of the characteristic classes of $P$?

 A: As a real vector bundle, $E^{\ast} \otimes E$ decomposes as the direct sum of two copies of the bundle $\mathfrak{su}(E)$ of trace-free skew-adjoint endomorphisms and two copies of the trivial bundle. This follows from the corresponding decomposition of $V^{\ast} \otimes V$ where $V$ is the defining $2$-dimensional representation of $U(2)$, as follows. First, the trace map $\text{tr} : V^{\ast} \otimes V \to \mathbb{C}$ has kernel $\mathfrak{sl}(V)$. Second, $\mathfrak{sl}(V)$ is the complexification of $\mathfrak{su}(V)$, so decomposes (as a real representation of $U(2)$) as a direct sum $\mathfrak{sl}(V) = \mathfrak{su}(V) \oplus i \mathfrak{su}(V)$. So, overall we have
$$E^{\ast} \otimes E \cong \mathfrak{su}(E) \oplus \mathfrak{su}(E) \oplus \mathbb{C}$$
(as a real vector bundle). The Whitney sum formula gives
$$w(E^{\ast} \otimes E) = w(\mathfrak{su}(E))^2$$
from which it follows that $w_4(E^{\ast} \otimes E) = w_2(\mathfrak{su}(E))^2$. We know that $w_4 \equiv c_2 \bmod 2$, so it remains to compute $c_2(E^{\ast} \otimes E)$, which we can do by the splitting principle. If $E$ has Chern roots $\alpha, \beta$ (so $c_1(E) = \alpha + \beta, c_2(E) = \alpha \beta$), then $E^{\ast}$ has Chern roots $-\alpha, -\beta$, so $E^{\ast} \otimes E$ has Chern roots $0, 0, \alpha - \beta, \beta - \alpha$. This gives
$$c(E^{\ast} \otimes E) = (1 + \alpha - \beta)(1 + \beta - \alpha) = 1 - (\alpha - \beta)^2 = 1 + 2 \alpha \beta - \alpha^2 - \beta^2$$
hence 
$$c_2(E^{\ast} \otimes E) = - c_1(E)^2 + 4 c_2(E)$$
so 
$$w_4(E^{\ast} \otimes E) \equiv c_1(E)^2 \equiv w_2(\mathfrak{su}(E))^2 \bmod 2.$$ 
To establish that we in fact have $w_2(\mathfrak{su}(E)) \equiv c_1(E) \bmod 2$ on the nose we need to think a bit about the cohomology of $BU(2)$. Its $\bmod 2$ cohomology is a polynomial ring on the Chern classes $c_1, c_2$, from which we can compute that the squaring map $H^2(BU(2), \mathbb{Z}_2) \to H^4(BU(2), \mathbb{Z}_2)$ is injective, so $w_2(\mathfrak{su}(E))$, which universally lives in $H^2(BU(2), \mathbb{Z}_2)$, is uniquely identified by its square. 
The computation of the Pontryagin class is similar. In this blog post you can find the proof that $V$ is a complex vector bundle then the first Pontryagin class of its underlying real vector bundle is $p_1(V) = c_1(V)^2 - 2 c_2(V)$. We computed $c_2$ above, and we have $c_1(E^{\ast} \otimes E) = 0$, so altogether
$$p_1(E^{\ast} \otimes E) = 2 c_1(E)^2 - 8 c_2(E).$$
By the Whitney sum formula for Pontryagin classes, this class is equal to $2 p_1(\mathfrak{su}(E))$ modulo $2$-torsion. But again thinking about the cohomology of $BU(2)$, its integral cohomology is again a polynomial ring on $c_1$ and $c_2$, and in particular is torsion-free, so we can ignore $2$-torsion and divide by $2$, which gives
$$p_1(\mathfrak{su}(E)) = c_1(E)^2 - 4 c_2(E)$$
as desired. 

More generally, can we express the characteristic classes of a bundle associated to a principal bundle $P$ in terms of the characteristic classes of $P$?

Yes, in the following sense. If $f : G \to H$ is any morphism of Lie groups, it induces a map $Bf : BG \to BH$ on classifying spaces. Applying this map allows you to associate an $H$-bundle to a $G$-bundle. This map further induces a map $H^{\ast}(Bf) : H^{\ast}(BH) \to H^{\ast}(BG)$ on cohomology, which universally describes characteristic classes for associated $H$-bundles in terms of characteristic classes for $G$-bundles. Above we're considering the map $BU(2) \to BGL_3(\mathbb{R})$ coming from the adjoint action of $U(2)$ on $\mathfrak{su}(2)$, and taking advantage of the fact that the cohomology of $BU(2)$ is very well-behaved. 
