It looks like you already had it partially down when you set the image:
BufferedImage b= bimg.getSubimage(j * w, i * h, w, h);
I'm referring to j*w and i*h
So why not draw them in the correct spot as well?
Changing:
g.drawImage(b,0,0,w,h,this);
Into:
g.drawImage(b, j*w , i*h ,w,h,this);