Masked Trajectory Models for Prediction, Representation, and Control