Implementing quantum gates and channels using linear optics