How about that: One byte for length, then n bytes for the number (least significant byte first). Repeat length+number as long as the previous length was 255.
This allows for arbitrarily large numbers, but is still easy to handle and doesn't waste too much memory.