Homebase has been bought out of administration, meaning up to 1,600 jobs have been saved.