Thousands of jobs are set to be saved after part of energy services firm Petrofac was bought out of administration.