This code works! y is a 1D NumPy array holding the class number of the samples.
temp_outs = numpy.zeros((y.shape[0], numpy.unique(y).size), dtype=numpy.uint8)
temp_outs[numpy.arange(y.shape[0]), numpy.uint8(y)] = 1

y = temp_outs