Factoring weakly compact operators