Using small-angle neutron scattering, we have imaged the magnetic flux line lattice (FLL) in the d-wave heavy-fermion superconductor CeCoIn5. At low fields we find a hexagonal FLL. Around 0.6 T this undergoes what is most likely a first-order transition to square symmetry, with the nearest neighbors oriented along the gap node directions. This orientation of the square FLL is consistent with theoretical predictions based on the d-wave order parameter symmetry.