Finding a low-rank basis in a matrix subspace