What level of Bmax are you using as that source doesn't compile on 1.20. You're not using Timage and TPixmap types for a start.
<edit> You also have an unnecessary 'cls' in your update_chunk method
<edit> You also have an unnecessary 'cls' in your update_chunk method