I found the solution. As I said we need to convert to float that too within range 0 to 1. Then we can convert it back after computing DCT:
imf = np.float32(imgcv1)/255.0 # float conversion/scale
dct = cv2.dct(imf) # the dct
imgcv1 = np.uint8(dct*255.0) # convert back to int