I found the following on Wolfram Math World:
I understand the first step, the integration by parts. For the first case, m is even, I am pretty sure it involves a binomial expansion of $(\frac{1}{2}(1-\cos(2x)))^n$, which arises from writing $\cos^{2n}(x)$ as $(cos^2(x))^n$, then writing $cos^2(x)$ as $\frac{1}{2}(1-cos(2x)$, but i do not know how they integrated from there.
Here is the link for reference: http://mathworld.wolfram.com/CosineIntegral.html