To find the right value of offset:
1. Take bias and get the average value (use Statistics in PI). It should be about 500 (anything between 100 and 1000 is ok).
2. If it is not then adjust the offset and repeat.
Once you have worked out the offset:
3. Turn camera to a light source so that the sensor is well lit and take an exposure that is a few seconds long. You want to saturate the sensor.
4. Use PI to measure the maximum value. It should be less but close to 65535.
5. If you changed the gain a lot in steps 3&4 maybe go back to step 1 and check the offset again and possibly repeat the whole procedure if needed.
6. Done.
Make sure you write down these values and never change them (unless you decide to repeat the procedure).
Although the sensor temperature does not affect the gain/offset much I like doing the measurements at the temperature that you will mainly be using your sensor.
Obligatory reading.
Regarding the exposure time:
1. The maximum exposure time will depend on the light pollution for your location. See
this,
this and
this.
2. For dim targets use your maximum exposure time.
3. For clusters use much shorter time or the stars will be saturated. Often even 30s is too long.
4. For very bright targets (Orion for example) you may want to combine short subs (so you don't overexpose the bright sections) and long subs (to get the faint details).