Pemex has recorded a net profit in the second quarter, reversing the big losses of a year ago, thanks to higher sales revenues and improved production.