The king numbers the bottles 1 to 1000 and writes the number in binary format on the label.
bottle 1 = 0000000001 bottle 250 = 0011111010 bottle 1000 = 1111101000
Then he takes Prisoners 1 through 10 and lines them up so Prisoner 1 take a sip from every bottle that has a 1 in its least significant bit. Prisoner 2 takes a sip from every bottle that has a 1 in its second bit, etc. And then Prisoner 10 takes a sip from every bottle with a 1 in its most significant bit.
Prisoner 10 9 8 7 6 5 4 3 2 1 Bottle 924 1 1 1 0 0 1 1 1 0 0
For instance, Bottle 924 would be sipped by prisoners 10, 9, 8, 5, 4, and 3. That way, if Bottle 924 was the poisoned one, only those prisoners would die.
After four weeks, the king lines the prisoners up in their bit order and reads each living prisoner as a 0 bit and each dead prisoner as a 1 bit. The number is the bottle of wine that was poisoned.
If the first sage looks and sees 2 black balls, he knows his must be white and will answer "white!" Otherwise he will have to pass because he can't be certain of the color on top of his head.
If the first sage passes, and the second sage sees the third one has a black ball on his head, the second sage will know he does not have a black one (otherwise the first sage would have answered), so he will answer "white!" If the third sage has a white ball on his head, then the second sage will pass also because he can't be certain of his color.
If both the first and second sage pass, then the third one knows he has a white ball on his head. If either of the first two answers, he knows he has a black ball on his head.