A 'General boundary' formulation for quantum mechanics and quantum gravity