Construction of exact constants of motion and effective models for many-body localized systems