Convenience good giant Greencore has reached an agreement with its rival Bakkavor about the terms of a £1.2 billion takeover.