IBM beat Q2 earnings and revenue expectations as software and consulting growth helped offset weaker infrastructure sales.